{php include wl_template('common/header');}
<!--<span class="price" style="display:none;">0.01</span>-->
<ul class="nav nav-tabs">
	<li {if $operation == 'base'}class="active"{/if}><a href="{php echo web_url('store/autoaddress', array('op' => 'base'))}">基本设置</a></li>
{if $checkfunction['status']}	
	<li {if $operation == 'display'}class="active"{/if}><a href="{php echo web_url('store/autoaddress', array('op' => 'display'))}">管理区域</a></li>
	<li {if $operation == 'post'}class="active"{/if}><a href="{php echo web_url('store/autoaddress', array('op' => 'post'))}">添加区域</a></li>
	{/if}
</ul>
<script>
	require(['bootstrap'],function($){
		$('.btn').hover(function(){
			$(this).tooltip('show');
		},function(){
			$(this).tooltip('hide');
		});
	});
</script>
<style>
.main_bd{padding-bottom:30px;height:180px;}
.plugins_wrp{padding:20px 30px}
.plugins_wrp .hd{margin-bottom:10px;padding-bottom:10px;border-bottom:1px solid #e7e7eb}
.plugins_wrp ul{margin-right:-24px;overflow:hidden;padding-left: 0px;}
.plugins_wrp .item_wrp{float:left;display:inline-block;*display:inline;*zoom:1;width:50%;position:relative;*width:49.9%}
.plugins_wrp .plugin_desc{padding-bottom:16px;color:#8d8d8d;margin: 14px 0;}
.table_wrp{padding:20px 30px}
.table_wrp .table_cell{height:40px;padding-left:20px;padding-right:20px}
.table_wrp .table_cell.plugin_name{width:450px}
.table_wrp .table_cell .privilege{color:#8d8d8d}
.table_wrp .table_cell .privilege .dot{font-style:normal;margin-right:5px}
.table_wrp .tbody .table_cell{padding-top:15px;padding-bottom:15px;vertical-align:top}
.table_wrp .plugin_logo{float:left;margin-right:10px}
.table_wrp .plugin_logo img{display:block;max-width:80px}
.table_wrp .plugin_info{overflow:hidden}
.table_wrp .plugin_info h4{font-weight:normal}
.table_wrp .plugin_info .desc{color:#8d8d8d}
.plugin_item{display:block;overflow:hidden;margin-right:24px;margin-bottom:24px;color:#222;height:92px;padding-left:94px;border:1px solid #e7e7eb}
.plugin_item:hover{text-decoration:none;background-color:#f4f5f9;border-color:#d9dadc}
.plugin_item .plugin_icon{position:absolute;width:92px;height:92px;background-color:#ccc;top:0;left:0}
.plugin_item .plugin_icon img {width: 92px;height: 92px;}
.plugin_item .plugin_status{position:relative;float:right;text-align:right;padding:35px 45px 35px 0}
.plugin_item .plugin_status .status_txt.warn{color:#e15f63}
.plugin_item .plugin_status .access{width:16px;height:16px;vertical-align:middle;display:inline-block;position:absolute;right:10px;top:40px}
.plugin_item .plugin_content{padding:10px 0 10px 20px;overflow:hidden}
.plugin_item .plugin_content .title{margin-bottom:4px;width:216px;font-size:14px;font-weight:400;font-style:normal;margin-top: 0px;}
.plugin_item .plugin_content .desc{color:#8d8d8d;font-size:12px;line-height:24px;width:238px;margin: 12px 0;}
table thead tr th, table tbody tr td {text-align: center; width: 10%;}
table thead tr th:last-child, table tbody tr td:last-child {text-align: right;}
 .selectDateadd{display:none;}
  .datedesc{display: block;line-height:30px;padding-left:3px;cursor:pointer;}
  .nactive{display:none;}
 #selectDate{position:absolute;width:90px;height:150px;top:130px;left:100px;border:1px solid black;background-color: white;}
</style>
{if $operation=='base'}
	<div class="panel panel-default">
	<div class="panel-body table-responsive" style="padding: 0px;">
		<div class="main_bd">
        <div class="plugins_wrp">
            <dl>
                <dd>
                    <ul id="js_plugins">
						<li class="item_wrp" style="width: 100%;">
							<div class="plugin_item">
								<!--<div class="plugin_icon"><img src="{TG_URL_WRES}images/function/definearea.png" style="cursor:pointer;"></div>-->
								<div  id="link-icon1" class="plugin_icon" >
									<div id="link-icon" style="display:none;width:100%;height:100%;position:absolute;background-color:rgba(0,0,0,0.3);cursor:pointer;">
										<img src="{TG_URL_WRES}images/3.svg"style="position:absolute;width:60%;left:20%;">
									</div>
									<img src="{TG_URL_WRES}images/function/definearea.png" style="cursor:pointer;">
								</div>
								<div class="plugin_status">
									<i class="access"></i>
									<span class="status_txt">
										{if $checkfunction['status']}	
											
										<div id="renewal" style="font-size:20px;margin-top:-30px;width: 60px;height:60px;border-radius:50%;font-weight:900;background-color:#ff5466;color:white;margin-right: -25px;text-align:center;line-height:60px;cursor:pointer;">续费</div>										
										<!--<input class="flag" type="checkbox" name="help"  value="{$setting['helpbuy']}" {if $setting['helpbuy'] == 1}checked{/if} />-->
										<span style="display:block;margin-left:-70px;color:#888;font-size:14px;">截止日期：{php echo date('Y-m-d', $checkfunction['endtime'])}</span>
										
										{else}
										
										<div id="buyDaifu" style="font-size:20px;margin-top:-20px;width: 60px;height:60px;border-radius:50%;font-weight:900;background-color:#ff5466;color:white;margin-right: -25px;text-align:center;line-height:60px;cursor:pointer;">购买</div>
										{/if}
									</span>
								</div>
								<div class="plugin_content">
									<h3 class="title">自定义区域</h3>
									<p class="desc" style="    width: 100%;">
										启用自定义区域功能后，粉丝地址将沿用自定义区域进行填写，非字定义区域内的地名将不显示。
										
									</p>
								</div>
							</div>
						</li>
					</ul>
                </dd>
            </dl>
        </div>
    </div>
	</div>
</div>
{if $checkfunction['status']}	
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" id="form1">
		<div class="panel panel-default">
		
			<div class="panel-body">
				<div class="form-group">
							<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">自定义区域</label>
							<div class="col-xs-12 col-sm-8">
								<label class="radio radio-inline" onclick="$('.addrtypemode').show();">
									<input type="radio" name="autoaddr" value="1" {if intval($setting['autoaddr']) == 1}checked="checked"{/if}> 开
								</label>
								<label class="radio radio-inline" onclick="$('.addrtypemode').hide();">
									<input type="radio" name="autoaddr" value="0" {if intval($setting['autoaddr']) == 0}checked="checked"{/if}> 关
							
							</div>
						</div>
						<div class="form-group addrtypemode">
<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">&nbsp;</label>						
							<div class="col-xs-12 col-sm-8">
							<label class="radio radio-inline" >
									<input type="radio" name="addrtype" value="0" {if intval($setting['addrtype']) == 0}checked="checked"{/if}> 省/市/县,区
							</label>
								<label class="radio radio-inline" >
								
									<input type="radio" name="addrtype" value="1" {if intval($setting['addrtype']) == 1}checked="checked"{/if}> 市/县,区/街道
								</label>
								<label class="radio radio-inline" >
									<input type="radio" name="addrtype" value="2" {if intval($setting['addrtype']) == 2}checked="checked"{/if}> 市/学校/单元
							</label>
							</div>
						</div>
				
				
				
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>
{/if}
{/if}
{if $operation == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" id="form1">
		<div class="panel panel-default">
			<div class="panel-heading">
				区域
			</div>
			<div class="panel-body">
				
				<div class="form-group"  >
							<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">顶级区域</label>
							<div class="col-xs-12 col-sm-8">
								<label class="radio radio-inline" onclick="$('.picmode').hide();">
									<input type="radio" name="mode" value="1" {if $auto['parentid']==0}checked="checked"{/if}> 是
								</label>
								<label class="radio radio-inline" onclick="$('.picmode').show();">
									<input type="radio" name="mode" value="2" {if $auto['parentid']!=0}checked="checked"{/if}> 否
								</label>								
							</div>
						</div>
			<div class="form-group picmode"  {if $auto['parentid']==0}style="display:none;"{/if}>
							<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">上级区域</label>
							<div class="col-sm-9 col-xs-12">
							<select name="provice2" id="provice2">
								
							<?php
							
								foreach($list as $val) {
									if($auto['parentid']==$val['id'])
									{
									echo '<option value='.$val['id'].' selected=selected>'.$val['name'].'</option>';
									}else{
									echo '<option value='.$val['id'].' >'.$val['name'].'</option>';
									}
									
								}
							?>
						  </select>
							
						</div>
						</div>
			
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>区域名称</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="catename" class="form-control" value="{$auto['name']}" />
					</div>
				</div>
				
				
				<!--<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">首页推荐</label>
					<div class="col-sm-9 col-xs-12">
						 <label class='radio-inline'>
							 <input type='radio' name='isrecommand' value=1' {if $category['isrecommand']==1}checked{/if} /> 是
						 </label>
						 <label class='radio-inline'>
							 <input type='radio' name='isrecommand' value=0' {if $category['isrecommand']==0}checked{/if} /> 否
						 </label>
					</div>
				</div>-->
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否显示</label>
					<div class="col-sm-9 col-xs-12">
						<label class='radio-inline'>
							<input type='radio' name='enabled' value=1' {if $auto['enabled']==1}checked{/if} /> 是
						</label>
						<label class='radio-inline'>
							<input type='radio' name='enabled' value=0' {if $auto['enabled']==0}checked{/if} /> 否
						</label>
					</div>
				</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>

{elseif $operation == 'display'}
<div class="main">
	<div class="category">
		<form action="" method="post" onsubmit="return formcheck(this)">
			<div class="panel panel-default">
				<div class="panel-body table-responsive">
					<table class="table table-hover">
						<thead>
							<tr>
								<th style="width:10px;"></th>
								
								<th style="width:300px;">区域名称</th>
								<th style="width:150px;">状态</th>
								<th style="width:150px;">操作</th>
							</tr>
						</thead>
						<tbody>
						{loop $list $row}
						<tr>
							<td>{if count($children[$row['id']]) > 0}<a href="javascript:;"><i class="fa fa-chevron-down"></i></a>{/if}</td>
							
							<td>
								<img src="{php echo tomedia($row['thumb']);}" width='30' height="30" onerror="$(this).remove()" style='padding:1px;border: 1px solid #ccc;float:left;' />
								<div class="type-parent">{if $row['level']==2}----{/if}{if $row['level']==3}--------{/if}{$row['name']}
								</div>
							</td>
							<td>
								{if $row['enabled']==1}
								<span class='label label-success'>显示</span>
								{else}
								<span class='label label-danger'>隐藏</span>
								{/if}
							</td>
							<td>
							<a href="{php echo web_url('store/autoaddress', array('op' => 'post', 'id' => $row['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="bottom" title="编辑"><i class="fa fa-edit"></i></a>&nbsp;&nbsp;
							<a href="{php echo web_url('store/autoaddress', array('op' => 'delete', 'id' => $row['id']))}" onclick="return confirm('确认删除此区域吗？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="bottom" title="删除"><i class="fa fa-times"></i></a>
							</td>
						</tr>
						{loop $children[$row['id']] $row}
						<tr>
							<td></td>
							<td>
								<input type="text" class="form-control col-lg-2" name="displayorder[{$row['id']}]" value="{$row['displayorder']}">
							</td>
							<td>
								<div style="padding-left:50px;height:30px;line-height:30px;background:url('./resource/images/bg_repno.gif') no-repeat -245px -545px;">{$row['name']}
									<img src="{php echo tomedia($row['thumb']);}" width='30' height="30" onerror="$(this).remove()" style='padding:1px;border: 1px solid #ccc;float:left;' />&nbsp;&nbsp;
								</div>
							</td>
							<td>
								{if $row['enabled']==1}
								<span class='label label-success'>显示</span>
								{else}
								<span class='label label-danger'>隐藏</span>
								{/if}
							</td>
							<td>
								<a href="{php echo web_url('store/autoaddress', array('op' => 'post', 'id' => $row['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="bottom" title="编辑"><i class="fa fa-edit"></i></a>&nbsp;&nbsp;
								<a href="{php echo web_url('store/autoaddress', array('op' => 'delete', 'id' => $row['id']))}" onclick="return confirm('确认删除此区域吗？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="bottom" title="删除"><i class="fa fa-times"></i></a>
							</td>
						</tr>
						{/loop}
						{/loop}
						
						<tr>
							<td></td>
							<td colspan="4">
								<a href="{php echo web_url('store/autoaddress',array('op' => 'post'))}"><i class="fa fa-plus-sign-alt"></i> 添加新区域</a>
							</td>
						</tr>
					
						<tr>
							<td></td>
							<td colspan="4">
								<input name="submit" type="submit" class="btn btn-primary" value="提交">
								<input type="hidden" name="token" value="{$_W['token']}" />
							</td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</form>
	</div>
</div>

{/if}
<!--模块购买-->
<div class="openDIV nactive" style="background-color:rgba(0,0,0,0.3);width:100%;height:100%;position:fixed;left:0px;top:0px;">
<div style="border-right:2px solid gray;border-bottom:2px solid gray;border-left:1px solid gray;border-top:1px solid gray;position:fixed;z-index:2;top:20px;left:0px;right:0px;margin-left:auto;margin-right:auto;width:400px;height:300px;background-color: white;overflow: hidden;">
			<div style="height:60px;width:100%;position:relative;font-size:28px;padding-left:20px;line-height:60px;background-color:#f9f9f9;">购买功能<img id="closed" style="position:absolute;right:40px;top:0px;bottom:0px;margin-top:auto;margin-bottom:auto;cursor:pointer;" src="{TG_URL_WRES}images/4.svg" width="20px" height="20px"></div>
			<p style="padding-left:20px;color:gray;margin-top:18px;">功能名称：<span id="template" style="padding-left:5px;color:#3c3c3c;">自定义区域</span></p>
			<p style="padding-left:20px;color:gray;">使用时长：<span style="padding-left:5px;color:#3c3c3c;cursor:pointer;" id="valueDate">3个月</span></p>
			<p style="padding-left:20px;color:gray;">优惠时长：<span style="padding-left:5px;color:#3c3c3c;" id="freeDate">3个月</span></p>
			<p style="padding-left:20px;color:gray;">支付方式：<img style="position:absolute;padding-top:2px;" width="18px" height="18px" src="{TG_URL_WRES}images/05.svg"><span style="position:absolute;padding-left:23px;color:#3c3c3c;"> 微信支付</span></p>
			<p  style="padding-left:20px;color:gray;">单月价格：<span style="padding-left:5px;color:orange;font-size:1.2em;"  id="valuePay">99.00</span>元</p>
			<p  style="padding-left:20px;color:gray;">总价格：<span style="padding-left:22px;color:orange;font-size:1.2em;"  id="totalPay">99.00</span>元</p>
			
			<img style="position:absolute;right:30px;bottom:50px;" src="{TG_URL_WRES}images/paylogo.png" width="150px" height="150px" id="cordvalue">
			<p id="shaomaid" style="margin-left:245px;margin-top:-20px;" >扫码完成支付<p/>
			<div id="selectDate" class="selectDateadd">
				<span class="datedesc">1个月</span>
				<span class="datedesc">3个月</span>
				<span class="datedesc">6个月</span>
				<span class="datedesc">12个月</span>
				<span class="datedesc">24个月</span>
			</div>
		</div>
		</div>
		<script>
			var linkicon=document.getElementById("link-icon");
		var linkicon2=document.getElementById("link-icon1");
		
		linkicon2.onmouseleave = function () {
			linkicon.style.setProperty( 'display', 'none' );
		}
		
		linkicon2.onmouseover = function () {
			linkicon.style.setProperty( 'display', 'block' );
		}
		
		linkicon.onclick=function (ev) {
			document.getElementById('detailimg').src='{TG_URL_WRES}images/function/zdyqy.jpg';
			document.getElementById("detailname").innerHTML = "自定义区域";
			document.getElementById("detailshow").style.setProperty("display","block");
		}
window.onload=function(){
	
	var intervalEvent;
	
	if (document.getElementById("buyDaifu")){
	var buyDaifu=document.getElementById("buyDaifu");
		buyDaifu.onclick=function(ev){
		if (openDIV.classList.contains("nactive")){
				var cordvalue=document.getElementById("cordvalue");							
				valuePay.innerHTML=0.01;
				valueDate.innerHTML="请选择时长";
				document.getElementById("totalPay").innerHTML="0.00";
				document.getElementById("freeDate").innerHTML=0+"个月";
				document.getElementById("shaomaid").style.display="none";										
				openDIV.classList.remove("nactive");			
		}
	}
	}
	var close=document.getElementById("closed"),
		openDIV=document.querySelector(".openDIV");
	close.addEventListener('click',function(ev){
		openDIV.classList.toggle("nactive");		
		window.clearInterval(intervalEvent);
		//ev.stopPropagation();
	},false);
	if (document.getElementById("renewal")){
	var renewal=document.getElementById("renewal");
	renewal.onclick=function(){
		if (openDIV.classList.contains("nactive")){
				var cordvalue=document.getElementById("cordvalue");							
				valuePay.innerHTML=0.01;
				valueDate.innerHTML="请选择时长";
				document.getElementById("totalPay").innerHTML="0.00";
				document.getElementById("freeDate").innerHTML=0+"个月";
				document.getElementById("shaomaid").style.display="none";										
				openDIV.classList.remove("nactive");	
		}
	}
}
	var valuePay=document.getElementById("valuePay");
		//var tmpnames=document.querySelectorAll(".tmpname");
		var valueDate=document.getElementById("valueDate"),
		selectDate=document.getElementById("selectDate");
		valueDate.onclick=function(){
			selectDate.classList.toggle("selectDateadd");
		}
		var orderno;
		var datedesc=document.querySelectorAll(".datedesc");
		var uniacid=124;//火蝶官方公众号ID
		for (var i=0;i<datedesc.length;i++){
			datedesc[i].onclick=function(ev){
			
				var n,m;
				for (var j=0;j<datedesc.length;j++){
					if (ev.target==datedesc[j]){
						switch (j){
							case 0:
							n=1;
							m=0;
							break;
							case 1:
							n=3;
							m=0;
							break;
							case 2:
							n=6;
							m=1;
							break;
							case 3:
							n=12;
							m=2;
							break;
							case 4:
							n=24;
							m=5;
							break;
						}
						var str=n+"个月";
						valueDate.innerHTML=str;
						document.getElementById("freeDate").innerHTML=m+"个月";
						document.getElementById("totalPay").innerHTML=((n-m)*Number(valuePay.innerHTML)).toFixed(2);
						var root='{$_W['siteroot']}';
						var buyuniacid=3;
						var tid=8154;
						orderno=RandomS();
						var surl=root+"app/index.php?i="+uniacid+"&c=entry&m=lexiangpingou&do=pay&ac=payfunction&id="+tid+"&num="+n+"&buyuniacid="+buyuniacid;
						var  baseurl;
						var data=new FormData();
						data.append('id',tid);						
						data.append('num',n);
						data.append('orderno',orderno);	
						data.append('uniacid',uniacid);	
						var url="{php echo web_url('store/setting/qr');}";
						var xhr=new XMLHttpRequest();
						xhr.onreadystatechange=function(){
							if (xhr.readyState==4){
								if ((xhr.status>=200 && xhr.status<300)|| xhr.status==304){
									
									document.getElementById("cordvalue").src="{TG_URL}"+"data/qrcode/"+uniacid+"/"+orderno+".png";
									
								}
							}
						}
						xhr.open("post",url,true);
						xhr.send(data);						
					}
				}
				document.getElementById("shaomaid").style.display="block";	
				selectDate.classList.toggle("selectDateadd");
				var buyFormdata=new FormData();
	/*验证是否购买*/var buyUrl="{php echo web_url('service/order_service',array('op'=>'check'))}";
					if (intervalEvent){
						window.clearInterval(intervalEvent);
					}							
					intervalEvent=window.setInterval(function(){
					
						var requestXhr=new XMLHttpRequest();
						requestXhr.onreadystatechange=function(){
						if (requestXhr.readyState==4){
							if ((requestXhr.status>=200 && requestXhr.status<300)||requestXhr.status==304){								
								if (JSON.parse(requestXhr.responseText).errno==0){
									util.tips(JSON.parse(requestXhr.responseText).message);
									openDIV.classList.add("nactive");
									window.clearInterval(intervalEvent); 
									location.reload();
								}
							}else{
								util.tips(requestXhr.status.toString());
							}
						}
					}
					requestXhr.open('post',buyUrl,true);
					buyFormdata.append("orderno",orderno);
					requestXhr.send(buyFormdata);
				},1000);	
			}
		}	
		function RandomS(){
		var now=new Date();
		var year=now.getFullYear();
		var month=now.getMonth()+1<10?0+""+(now.getMonth()+1):now.getMonth()+1;
		var date=now.getDate()<10?0+""+now.getDate():now.getDate();
		var time=now.getHours()<10?0+""+now.getHours():now.getHours();
		var minutes=now.getMinutes()<10?0+""+now.getMinutes():now.getMinutes();
		var seconds=now.getSeconds()<10?0+""+now.getSeconds():now.getSeconds();
		var randoms=parseInt(Math.random()*9+1)+""+parseInt(Math.random()*9)+""+parseInt(Math.random()*9)+""+parseInt(Math.random()*9)+""+parseInt(Math.random()*9);
		return month+""+date+""+time+""+minutes+""+seconds+""+randoms;
		}
}
$(function(){
	require(['bootstrap.switch'],function($){
		$('.flag:checkbox').bootstrapSwitch({onText: '启用', offText: '禁用'});
		$('.bootstrap-switch-wrapper').click(function(e){
			e.stopPropagation();
			$.post("{php echo web_url('store/autoaddress/ajax')}",function(d){
				if(!d.errno){
					util.tips(d.message);
				}
			},"json");
		});
	});
	// 新建
		$('.js-create').click(function(e) {
			$('#order-remark-container').show();
			$('.panel').css("opacity","0.2");$('.nav').css("opacity","0.2");
		});
		$('.js-cancel,.close').click(function(e) {
			$('#order-remark-container').hide();
			$('.panel').css("opacity","1");$('.nav').css("opacity","1");
		});
		$('.js-order-remark-post').click(function() {
			var order_id = $(this).attr('order-id');
			var remark = $('#remark').val();
			$.post("{php echo web_url('application/helpbuy/create')}",{id:order_id,remark:remark},function(d){
				if(!d.errno){
					if(order_id){
						$('#name'+order_id).html(remark);
					}else{
						var data = '<tr data-toggle="popover" data-trigger="hover" data-placement="left" class="js-goods-img">'
									+'<td class="line-feed text-left">'+remark
									+'</td>'
									+'<td class="text-left">'
										+'<a href="javascript:;" class="js-edit" order-id="'+d.id+'">编辑</a> - '
										+'<a href="javascript:;" class="js-delete" order-id="'+d.id+'">删除</a>'
									+'</td>'
								+'</tr>';
						
						$('#add').append(data);
					}
					
				}
			},"json");
			$('#order-remark-container').hide();
			$('.panel').css("opacity","1");$('.nav').css("opacity","1");
		});
		$('.js-edit').click(function(e) {
			var order_id = $(this).attr('order-id');
			var order_name = $(this).attr('order-name');
			$('#remark').val(order_name);
			$('.js-order-remark-post').attr("order-id",order_id);
			$('#order-remark-container').show();
			$('.panel').css("opacity","0.2");
			$('.nav').css("opacity","0.2");
		});
		$('.js-delete').click(function(e) {
			e.stopPropagation();
			var order_id = $(this).attr('order-id');
			var _this = $(this);
			util.nailConfirm(this, function(state) {
				if(!state) return;
				_this.parent().parent().remove();
/*url*/				$.post("{php echo web_url('application/helpbuy/delete');}", { id : order_id }, function(data){
						util.tips(data.message);
				}, 'json');
			}, {html: "确定删除！"});
			
		});
	$(".scrollLoading").scrollLoading();
	var $pop = null;
	$('.scrollLoading').hover(function(){
		var img = $(this).attr('src');
		var obj = this;
		var $pop = util.popover(obj, function($popover, obj){
			obj.$popover = $popover;
		}, '<div><img src="'+img+'" style="max-width:200px; max-height:200px;"></div>');
	}, function(){
		this.$popover.remove();
	});
});
</script>
{php include wl_template('common/footer');}
